﻿using System;
using System.Data;
using System.Data.OracleClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/// <summary>
/// 用户操作类
/// </summary>
public class UserPage : System.Web.UI.Page
{

    private const string _defaultPass = "123456";
    private const string _roleSys = "sys_manage";

    public string RoleSys
    {
        get { return _roleSys; }
    } 


    public static string DefaultPass
    {
        get { return UserPage._defaultPass; }
    } 

	public UserPage() { }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (Session["LoginUser"] == null)
        {
            Response.Redirect("~/ULogin.aspx");
        }
    }

    protected void JQueryAlert(string argMessage)
    {
        JQFunction("alert('" + argMessage + "');");
    }

    protected void JQFunction(string argFunction)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "sysinfo", "$(function(){" + argFunction + "});", true);
    }

    protected string GetPubDataName(string argType,string argCode)
    {
        string sqlstr = "SELECT DATA_NAME FROM u_pub_data_t WHERE DATA_TYPE = :DATA_TYPE AND DATA_CODE = :DATA_CODE";
        OracleParameter[] _params = {
                new OracleParameter(":DATA_TYPE",OracleType.VarChar,50),
                new OracleParameter(":DATA_CODE",OracleType.VarChar,20)
            };
        _params[0].Value = argType;
        _params[1].Value = argCode;
        return OracleHelper.ExecuteScalar(sqlstr, CommandType.Text, _params).ToString();
    }

    protected DataTable GetUser(string argLogin)
    {
        string sqlStr = @"SELECT login_name,real_name,if_valid,join_date,organ FROM u_user_info_t WHERE login_name=:login_name";
        OracleParameter[] _params = {
                new OracleParameter(":login_name",OracleType.VarChar,16)
            };
        _params[0].Value = argLogin;
        return OracleHelper.ExecuteDataSet(sqlStr, CommandType.Text, _params).Tables[0];
    }
}
